package com.tjp.eight.ui.fragment.mywallet.details;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;
import com.tjp.eight.utils.AppUtils;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/3/28.
 */
public class WalletListPresenter extends BasePresenterImpl<WalletListView> {
    private WalletListService service = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(WalletListService.class);

    public WalletListPresenter(WalletListView view) {
        attachView(view);
    }

    public void loadData(String pJson) {
        RequestBody body = AppUtils.getRequestBody(pJson);
        addSubscription(service.loadData(body), new SubscribeCallBack<>(new NetCallBack<WallistRModel>() {
            @Override
            public void onSuccess(WallistRModel model) {
                view.loadSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {

            }

            @Override
            public void onCompleted() {

            }
        }));
    }
    public void loadMData(String pJson) {
        RequestBody body = AppUtils.getRequestBody(pJson);
        addSubscription(service.loadData(body), new SubscribeCallBack<>(new NetCallBack<WallistRModel>() {
            @Override
            public void onSuccess(WallistRModel model) {
                view.loadMSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {

            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
